/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package merlion.scm.rmpm.entity;

import java.io.Serializable;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.ManyToOne;
import javax.persistence.CascadeType;
import javax.persistence.FetchType;
import javax.persistence.OneToOne;
import merlion.crm.slcm.entity.Address;

/**
 *
 * @author Yuwei
 */
@Entity
public class RawMaterialRequestForQuotation implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    private String rfqNumber;
    private Timestamp rfqDate;
    @OneToMany(targetEntity=RawMaterialItemLine.class, cascade={CascadeType.PERSIST,CascadeType.MERGE}, fetch=FetchType.EAGER)
    private List<RawMaterialItemLine> rawMaterialItemLines;
    @ManyToOne(targetEntity=Supplier.class, cascade={CascadeType.PERSIST,CascadeType.MERGE}, fetch=FetchType.EAGER)
    private Supplier supplier;
    @OneToOne(targetEntity=RawMaterialPurchaseOrder.class, cascade={CascadeType.PERSIST, CascadeType.MERGE}, fetch=FetchType.EAGER)
    private RawMaterialPurchaseOrder rmPo;
    @OneToOne(targetEntity=Address.class, cascade={CascadeType.PERSIST, CascadeType.MERGE}, fetch=FetchType.EAGER)
    private Address ourAddress;
    
    public RawMaterialRequestForQuotation(){
        rfqNumber = "";
        rfqDate = new Timestamp(new Date().getTime());
        rawMaterialItemLines = new ArrayList<RawMaterialItemLine>();
        supplier = new Supplier();
        rmPo = null;
        ourAddress = new Address();
    }
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Address getAddress() {
        return ourAddress;
    }

    public void setAddress(Address address) {
        this.ourAddress = address;
    }

    public Collection<RawMaterialItemLine> getRawMaterialItemLines() {
        return rawMaterialItemLines;
    }

    public void setRawMaterialItemLines(List<RawMaterialItemLine> rawMaterialItemLines) {
        this.rawMaterialItemLines = rawMaterialItemLines;
    }

    public Timestamp getRfqDate() {
        return rfqDate;
    }

    public void setRfqDate(Timestamp rfqDate) {
        this.rfqDate = rfqDate;
    }

    public String getRfqNumber() {
        return rfqNumber;
    }

    public void setRfqNumber(String rfqNumber) {
        this.rfqNumber = rfqNumber;
    }

    public RawMaterialPurchaseOrder getRmPo() {
        return rmPo;
    }

    public void setRmPo(RawMaterialPurchaseOrder rmPo) {
        this.rmPo = rmPo;
    }

    public Supplier getSupplier() {
        return supplier;
    }

    public void setSupplier(Supplier supplier) {
        this.supplier = supplier;
    }
    
    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        if (!(object instanceof RawMaterialRequestForQuotation)) {
            return false;
        }
        RawMaterialRequestForQuotation other = (RawMaterialRequestForQuotation) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "merlion.scm.rmpm.entity.RawMaterialRequestForQuotation[ id=" + id + " ]";
    }
    
}
